{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d2232759-c86e-4c8f-8ca7-88fc9a2eb85b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "493b09c4-4302-4534-a605-cf3b764923b3",
   "metadata": {},
   "source": [
    "# 如果不具备部署条件，可以使用大模型厂商提供的API服务，以硅基流动为例"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "97b76026-1883-414a-8dd1-99e6c30df935",
   "metadata": {},
   "source": [
    "硅基流动官网：https://cloud.siliconflow.cn/me/models"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "339f6a37-cd36-4fd7-b96c-ca07e95f1c71",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "Hello! How can I assist you today? 😊\n"
     ]
    }
   ],
   "source": [
    "from openai import OpenAI\n",
    "\n",
    "client = OpenAI(\n",
    "    base_url=\"https://api.siliconflow.cn/v1\",\n",
    "    api_key=\"sk-deapwwpqcnsttyrlzvezdhmxocgzztukvyixagxygcrqgpjw-\"  \n",
    ")\n",
    "\n",
    "response = client.chat.completions.create(\n",
    "    model=\"Qwen/Qwen3-8B\",\n",
    "    messages=[\n",
    "        {\"role\": \"system\", \"content\": \"You are a helpful assistant\"},\n",
    "        {\"role\": \"user\", \"content\": \"Hello\"},\n",
    "    ],\n",
    "    stream=False\n",
    ")\n",
    "\n",
    "print(response.choices[0].message.content)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
